let idNum: number = 1
export interface DropBoxOpt {
  // 宽
  w: number
  // 高
  h: number
  // x坐标
  x: number
  // y坐标
  y: number
  // 图片
  img: any
  // 初速度
  v?: number
}
export default class DropBox {
  private w: number
  private h: number
  private x: number
  private y: number
  private img: any
  private id: number
  private v: number
  private type: string = 'dropBox'
  private isDestory: boolean = false
  private creatTime: number
  constructor(opt: DropBoxOpt) {
    this.id = idNum += 1
    this.x = opt.x || 20
    this.y = opt.y || 20
    this.w = opt.w || 20
    this.h = opt.h || 20
    this.img = opt.img
    this.v = opt.v || 0
    this.creatTime = Date.now()
  }

  // 更新数据
  updata() {
    this.y = this.y + this.getStep()
    this.isDestory = this.y > window.screen.height + this.h
  }

  getStep(): number {
    // return 0.1
    return (this.v += Math.random() / 10)
  }

  destory() {
    this.img = null
  }
}
